<!-- 页面中的内容 -->

<div class="main-div">
    <form name="main_form" method="POST" action="{:url('edit')}">
        <table cellspacing="1" cellpadding="3" width="100%">
        	<tr>
                <td class="label">所属类型：</td>
                <td>
                    <select name="type_id">
						<option value="">选择类型</option>
                        {volist name="types" id="type"}
						<option value="{$type.tid}" {if condition="$type['tid'] eq $attr['tid']"}selected="selected"{/if}>{$type.type_name}</option>
						{/volist}
					</select>
                </td>
            </tr>
            <tr>
                <td class="label">属性名称：</td>
                <td>
                    <input  type="text" name="attrName" value="{$attr.attr_name}" />
                </td>
            </tr>
            <tr>
                <td class="label">属性类型：</td>
                <td>
                    <input type="radio" name="attrType" value="0" {if condition="!$attr['attr_type']"}checked="checked"{/if} />唯一 
                    <input type="radio" name="attrType" value="1" {if condition="$attr['attr_type']"}checked="checked"{/if}  />可选 
                </td>
            </tr>
            <tr class="attrType_btn">
                <td class="label">录入方式：</td>
                <td>
                    <input type="radio" name="inputType" value="0" {if condition="!$attr['input_type']"}checked="checked"{/if} />手动输入 
                    <input type="radio"  name="inputType" value="1" {if condition="$attr['input_type'] ===1"}checked="checked"{/if} />在列表中选择  
                    <input type="radio" name="inputType" value="2" {if condition="$attr['input_type'] ===2"}checked="checked"{/if} />手动输入多选项  
                </td>
            </tr>
            <tr style="display: none;">
                <td class="label">可选值：</td>
                <td>
                	<textarea name="attr_option_values" rows="3" class="60">{$attr.attr_value}</textarea><span style="color:#999;">（请用英文状态下的逗号","分割多个值）</span>
                </td>
            </tr>
            <tr>
                <td class="label">排序：</td>
                <td>
                    <input type="text" name="sort" value="{$attr.sort}" checked="checked" style="width:30px;text-align: center;" />  
                    <input type="hidden" name="attrId" value="{$attr.aid}" >
                </td>
            </tr>
            <tr>
                <td colspan="99" align="center">
                    <input type="submit" class="button" value=" 确定 " />
                    <input type="reset" class="button" value=" 重置 " />
                </td>
            </tr>
        </table>
    </form>
</div>
<script>
    //属性类型为多选时，展示可选值列表
    var inputs = $('.attrType_btn').find('input');
    var oTr = inputs.eq(0).parents('tr').next();
    
    //点击事件
    inputs.click(function(){

        //判断多选按钮是否选中
        if( inputs.not(inputs.eq(0)).is(':checked') ){

            oTr.css('display','table-row');

        }else{

            oTr.css('display','none');

        }

    });

    //打开页面先判断，多选是否被选中
    if( inputs.not(inputs.eq(0)).is(':checked') ){

        oTr.css('display','table-row');

    }
</script>